#include <myhead.h>
int main(int argc, const char *argv[])
{
	char fd[20]="域套接字";
	//1、创建域套接字
	int S=socket(AF_UNIX,SOCK_STREAM,0);
	//2、绑定新的预套接字文件
	struct sockaddr_un addr={0};
	addr.sun_family=AF_UNIX;
	strcpy(addr.sun_path,fd);
	if(access(fd,F_OK)!=-1){
		remove(fd);
	}
	if(bind(S,(struct sockaddr*)&addr,sizeof(addr))==-1){perror("绑定失败");return -1;}
	listen(S,10);
	struct sockaddr_un addt={0};
	int len=sizeof(addt);
	int C=accept(S,(struct sockaddr*)&addt,&len);
	while(1)
	{
		char buf[128]={0};
		int res=read(C,buf,128);
		if(res==0)break;
		printf("接收到的消息为:%s\n",buf);
	}



	return 0;
}
